const express = require('express')
const router = express.Router()
const authMiddleware = require('../middleware/authMiddleware') // 引入 Token 验证中间件
const UsersControllers = require('../controllers/usersControllers')
const EmailControllers = require('../controllers/emailControllers')


// 不需要 Token 验证的路由
router.post('/register', UsersControllers.addNewUser) // 注册
router.get('/acc/:acc',UsersControllers.getUserByAccount) // 根据账号获取用户
router.post('/login', UsersControllers.login) // 登录

// 需要 Token 验证的路由
router.delete('/:id', authMiddleware, UsersControllers.delUserById) // 删除用户
router.put('/:id', authMiddleware, UsersControllers.updateUserById) // 更新用户
router.get('/', authMiddleware, UsersControllers.getAllUsers) // 获取所有用户
router.get('/id/:id', authMiddleware, UsersControllers.getUserById) // 根据 ID 获取用户信息
router.get('/layout', authMiddleware, UsersControllers.layout) // 退出登录
router.post('/uploadAvatar', UsersControllers.uploadAvatar) // 更改用户头像
router.get('/pay',authMiddleware, UsersControllers.getPayQRCode) // 获取支付二维码
router.post('/ban', authMiddleware, UsersControllers.banUser) // 封禁用户
router.get('/mh/:account',authMiddleware, UsersControllers.getUserByAccMH) // 根据账号模糊查询用户
router.post('/release/:id',authMiddleware, UsersControllers.releaseUser) // 解封用户
router.get('/idPlus/:id', authMiddleware, UsersControllers.getUserByIdPlus) // 管理员根据 ID 获取用户全部信息
router.post('/updetails/:id',authMiddleware, UsersControllers.updateUserDetailsById) // 更新用户详细信息
router.post('/resetPwd/:id',authMiddleware, UsersControllers.resetPwdById) // 修改用户密码
router.post('/cz', UsersControllers.updateMoneyById) // 充值
router.post('/tx',authMiddleware, UsersControllers.tiXian) // 提现
router.post('/cj', UsersControllers.cunJian) // 存件
router.post('/qj/:quCode', UsersControllers.quJian) // 取件
router.post("/email", EmailControllers.sendEmail);

module.exports = router